#ifndef FOUNDATION_DATA_ACQ_DEVICETASK_H
#define FOUNDATION_DATA_ACQ_DEVICETASK_H
#include "dbms_device.h"
#include <vendor_global.h>
#include <string>
#include <functional>
#include <thread>
#include "downlink_connect.h"
#include <protocol/xcom_process.h>

namespace data_acq {
using SubscribeCallback =
	std::function<bool(const dbms::Device_t &, const dbms::AcqData_t &)>;
using SubscribeExceptionCallback =
	std::function<void(const dbms::Device_t &, const std::string &)>;
using CommunicationCallback = protocol::XComSend;
using ParseRecv = protocol::ParseRecv;

class DeviceTask {
public:
	DeviceTask(const dbms::Device_t &device);
	virtual ~DeviceTask();
	std::string ID();
	struct DeviceListener {
		SubscribeCallback subscribe;
		SubscribeExceptionCallback subscribeException;
		CommunicationCallback communicationCallback;
	};
	void OnAcq(const DeviceListener &listener,
		const std::vector<dbms::Funcpoint_t> &funcList,
		const std::vector<libxcom::OpValue> &params = {});

	dbms::Device_t &GetDevice();

	std::vector<dbms::Funcpoint_t> GetAcqFuncpoints();
	dbms::Funcpoint_t GetFuncpoint(int32_t funcId);

private:
	dbms::Device_t device_;
};
} // namespace data_acq

#endif // FOUNDATION_DATA_ACQ_DEVICETASK_H